﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace QuanLyThuNgan
{
    public class CaThuNganDAO
    {
        public string m_Insert_refe(CaThuNganDTO _info)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_CaThuNgan_Insert_refe {0},{1},'{2}','{3}'",
            _info.IIDCaLamViec, _info.IIDThuNgan, _info.DaNgayDangKy, _info.SMaDonVi);
            return _sql;
        }
        public bool m_Insert(CaThuNganDTO _info)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_CaThuNgan_Insert {0},{1},'{2}',{3},'{4}','{5}',{6},{7},{8},{9},'{10}','{11}',{12},'{13}'",
             _info.IIDCaLamViec, _info.IIDThuNgan, _info.DaNgayDangKy, _info.SsGioNopTien, _info.DaNgayHetCa, _info.SsGioHetCa, _info.IIDHetCa,
             _info.ITongSoTien, _info.ITienDaXacNhan, _info.ITienChuaXacNhan, _info.DaNgayNopTien, _info.SsGioNopTien, _info.IIDNguoiNhanTien, _info.SMaDonVi); 
            return Uit.it_SQL.ExecuteNonQuery(_sql, false);
           // return _sql;
        }
        public bool m_Update(CaThuNganDTO _info)
        {
            string _sql = string.Format("exec usp_ThuNgan_CaThuNgan_Insert {0},{1},'{2}',{3},'{5}',{6},{7},{8},{9},'{10}','{11}',{12},'{13}'",
             _info.IIDCaLamViec, _info.IIDThuNgan, _info.DaNgayDangKy, _info.DaNgayHetCa, _info.SsGioHetCa, _info.IIDHetCa,
             _info.ITongSoTien, _info.ITienDaXacNhan, _info.ITienChuaXacNhan, _info.DaNgayNopTien, _info.SsGioNopTien, _info.IIDNguoiNhanTien, _info.SMaDonVi);
            return Uit.it_SQL.ExecuteNonQuery(_sql, false);
            //return _sql;
        }
        public string m_Update_refe(CaThuNganDTO _info)
        {
            string _sql = string.Format("exec usp_ThuNgan_CaThuNgan_Insert {0},{1},'{2}',{3},'{4}','{5}',{6},{7},{8},{9},'{10}',{11},'{12}'",
 _info.IIDCaLamViec, _info.IIDThuNgan, _info.DaNgayDangKy,_info.SsGioHetCa, _info.IIDHetCa,
 _info.ITongSoTien, _info.ITienDaXacNhan, _info.ITienChuaXacNhan, _info.DaNgayNopTien, _info.SsGioNopTien, _info.IIDNguoiNhanTien, _info.SMaDonVi);
            return _sql;
        }
        public string m_Delete(CaThuNganDTO _info)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_CaThuNgan_Delete {0},{1}", _info.IIDCaThuNgan,_info.IIDThuNgan);
           // return Uit.it_SQL.ExecuteNonQuery(_sql, false);
            return _sql;
        }

        public DataTable m_SelectAllCaThuNgan()
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_CaThuNgan_SelectAll");
            return Uit.it_SQL.getDataTable(_sql, null, "");
        }
        public DataTable m_SelectAllCaThuNgan_all(int IDThuNgan, string NgayDangKy)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_CaThuNgan_DSDangHoatDong {0},'{1}'",IDThuNgan,NgayDangKy);
            return Uit.it_SQL.getDataTable(_sql);
        }
        public DataTable m_SelectAllCaThuNgan_all_moi(int IDThuNgan)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_CaThuNgan_DSDangHoatDong_Moi {0}", IDThuNgan);
            return Uit.it_SQL.getDataTable(_sql);
        }
        
        public DataTable m_SelectAll_NguoiDung_CaThuNgan(int IDCaThuNgan,int idnguoidung)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_PhanQuyen_NguoiDung_TheoIDCaThuNgan {0},{1}", IDCaThuNgan, idnguoidung);
            return Uit.it_SQL.getDataTable(_sql);
        }
   
        public DataTable m_SelectKiemTra_IDCaNguoiDung(int idnguoidung)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_CaThuNgan_KiemTra {0}", idnguoidung);
            return Uit.it_SQL.getDataTable(_sql);
        }
        // dung
         public DataTable m_SelectAll_XacNhanHetCa(int idnguoidung)
           {
               string _sql = string.Format("exec usp_ThuNgan_XacNhanHetCa_SelectAll {0}", idnguoidung);
               return Uit.it_SQL.getDataTable(_sql);
           }

           public bool m_UpdateXacNhanHetCa(CaThuNganDTO _info)
           {
               string _sql = string.Format("exec usp_ThuNgan_XacNhanHetCa_Update {0},'{1}','{2}',{3}",
            _info.IIDCaThuNgan, _info.DaNgayHetCa, _info.SsGioHetCa, _info.IIDHetCa);
               return Uit.it_SQL.ExecuteNonQuery(_sql, false);
           }

           public DataTable m_SelectDanhSachXacNhanNopTien(string TuNgay, string DenNgay)
           {

               string _sql = string.Format("exec usp_ThuNgan_XacNhanNopTien_SelectDanhSach '{0}','{1}'",TuNgay, DenNgay);
               return Uit.it_SQL.getDataTable(_sql);
           }

           public DataTable m_SelectChiTietNopTien(int _IDCaThuNgan)
           {
               string _sql = string.Format("exec usp_ThuNgan_BaoCaoNopTien {0}",_IDCaThuNgan);
               return Uit.it_SQL.getDataTable(_sql);
           }

           public bool m_UpdateXacNhanThuTien(CaThuNganDTO _info)
           {
               string _sql = string.Format("exec usp_ThuNgan_XacNhanThuTien_Update {0},{1},{2},{3},'{4}','{5}',{6},{7}",
            _info.IIDCaThuNgan, _info.ITongSoTien, _info.ITienDaXacNhan, _info.ITienChuaXacNhan, _info.DaNgayNopTien,_info.SsGioNopTien, _info.IIDNguoiNhanTien, _info.IHoanTien);
               return Uit.it_SQL.ExecuteNonQuery(_sql, false);

           }

        //danh sach nop tien--------------------------------------
           public DataTable m_SelectDanhSachNopTien(string TuNgay, string DenNgay)
           {

               string _sql = string.Format("exec usp_ThuNgan_DanhSachNopTien_SelectNopTien '{0}','{1}'", TuNgay, DenNgay);
               return Uit.it_SQL.getDataTable(_sql);
           }

        //in het ca--------------------------------------------------------------
           public DataTable m_SelectInHetCa(int idnguoidung)
           {

               string _sql = string.Format("exec usp_ThuNgan_InHetCa_Select {0}", idnguoidung);
               return Uit.it_SQL.getDataTable(_sql);
           }
       
    }
}
